<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>数字化转型创意大赛决赛</title>
  <!-- import CSS -->
	<link rel="stylesheet" href="http://npm.elemecdn.com/mint-ui@2.2.13/lib/style.css">
	<link rel="stylesheet" href="/static/main.css">
</head>
<body>
  <div id="app"  class="loadHide">
  	<mt-header fixed title="数字化转型创意大赛决赛"></mt-header>
  	<div style="margin-top:40px;width:100%">
  		<!-- <img src="/static/pic1.jpg" style="width:100%;display:block;" /> -->
  	</div>
  	<div style="margin-top:10px;">
		<mt-field label="用户名" placeholder="请输入用户名" v-model="loginvo.username"></mt-field>
		<mt-field label="密码" placeholder="请输入密码" type="password" v-model="loginvo.password"></mt-field>
	</div>
    <mt-button size="large" @click.native="toLogin" type="primary">登录</mt-button>
  </div>
</body>
<!-- import Vue before Mint UI -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<!-- import JavaScript -->
<script src="http://npm.elemecdn.com/mint-ui@2.2.13/lib/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.0"></script>
  <script src="/static/common.js"></script>
  <script>
  	setCookie('token', '', 365);
    new Vue({
      el: '#app',
      data:{
      	loginvo:{
      	}
      },
      mounted:function(){
        document.getElementById('app').setAttribute('class','');
      },
      methods: {
        toLogin: function() {
          var me = this;
          if(!me.loginvo.username){
            this.$toast('请输入用户名');
            return;
          }
          if(!me.loginvo.password){
            this.$toast('请输入密码');
            return;
          }
          this.$indicator.open();
          this.$http.post('/ajaxlogin', me.loginvo).then(response => {
          	this.$indicator.close();
			if(response.body.flag){
				this.$toast('登陆成功');
				setCookie('token', response.body.token, 365);
				location.href = '/';
			}
			else{
				this.$toast(response.body.msg);
			}
		  }, response => {
		    this.$indicator.close();
		    this.$toast('登陆失败，网络错误');
		  });
        }
      }
    });
  </script>
</html>